package com.upf1sh.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.upf1sh.bean.RebootData;
import com.upf1sh.bean.Thingmodel;
import com.upf1sh.service.RebootDataService;
import com.upf1sh.service.ThingmodelService;
import com.upf1sh.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @Title: RebootDataCtrl
 * @Package com.upf1sh.controller
 * @Author: ZhaoXu
 * @CreateTime: 2025/1/3 22:23
 */

@RestController
@RequestMapping("/reboot")
public class RebootDataCtrl {
    @Autowired
    private RebootDataService rebootDataService;

    @GetMapping("list")
    public Result getList(RebootData rebootData) {
        IPage<RebootData> thingmodelIPage = rebootDataService.getPage(rebootData);
        return Result.ok().data("data", thingmodelIPage);
    }

    @GetMapping("/{id}")
    public Result getOne(@PathVariable Integer id) {
        RebootData rebootData = rebootDataService.getRebootData(id);
        return Result.ok().data("data", rebootData);
    }

    @PostMapping("/add")
    public Result add(@RequestBody RebootData rebootData) {
        rebootDataService.insertRebootData(rebootData);
        return Result.ok();
    }

    @PostMapping("edit")
    public Result edit(@RequestBody RebootData rebootData) {
        rebootDataService.updateRebootData(rebootData);
        return Result.ok();
    }

    @PostMapping("del/{id}")
    public Result del(@PathVariable Integer id) {
        rebootDataService.deleteRebootData(id);
        return Result.ok();
    }
}


